home *** CD-ROM | disk | FTP | other *** search
- Path: news.bridge.net!news
- From: David Byrden <100101.2547@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Q: how to store class member function pointers in class B
- Date: 27 Feb 1996 17:18:54 GMT
- Organization: self-employed
- Message-ID: <4gvedu$cj8@news.bridge.net>
- References: <4gvdei$rra@news.Silvaco.COM>
- NNTP-Posting-Host: ppp-mia2-71.bridge.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1N (Windows; I; 16bit)
-
-
- >>>>>>>>
- class Button : public ProtoButton {
- void (Panel::*function)(void);
-
- void inheritedCallback(void) {
- this->*function(); woops!
- }
-
- Button((Panel::*func)(void)) {
- function = func;
- }
- }
- <<<<<<<<<
-
-
- Mike;
-
- Imagine that the "this" pointer is passed as an 'invisible' parameter
- to all nonstatic member functions (which is the case in most compilers).
- Its type is checked, otherwise you would be able to use members of one
- class on another class - which is what your code tries to do.
-
- You are trying to call a member function of class Panel, but the base
- address that you are specifying is the address of a Button.
-
- You will need to store the address of a Panel object as well.
-
- David
-
-
-